package com.yzh.wanandroid.view

import android.content.Context
import android.util.AttributeSet
import android.util.Log
import androidx.appcompat.widget.AppCompatImageView
import androidx.databinding.BindingMethod
import androidx.databinding.BindingMethods

/**
 * 通过databinding 加载网络图片
 */
@BindingMethods(
    BindingMethod(
        type = IoadImageView::class,
        attribute = "loadImage",
        method = "load"
    )
)
class IoadImageView : AppCompatImageView {
    constructor(context: Context) : super(context)
    constructor(context: Context, attrs: AttributeSet) : super(
        context, attrs
    )

    constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(
        context, attrs, defStyleAttr
    )

    fun load(url: String) {
        Log.i("IoadImageView", "url = $url")
        com.yzh.wanandroid.utils.loadOnDiskCache(this.context,this,url,true)
    }
}